package com.hellpro.lolbox.mine.model;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hellpro.lolbox.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 类描述:
 * 创建人:阿犇
 * 创建时间:2016/10/25
 * 备注:
 */

public class MineLvAdapter extends BaseAdapter {

    private String[] content;
    private int[] imgs;

    public MineLvAdapter(String[] content, int[] imgs) {
        this.content = content;
        this.imgs = imgs;
    }

    @Override
    public int getCount() {
        return content.length;
    }

    @Override
    public Object getItem(int position) {
        return content[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.mine_lv_item, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mineContentTv.setText(content[position]);
        holder.mineContentIv.setImageResource(imgs[position]);
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.mine_content_iv)
        ImageView mineContentIv;
        @BindView(R.id.mine_content_tv)
        TextView mineContentTv;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
